<?php
/**
 * Created by PhpStorm.
 * User: Ysll <754060604@qq.com>
 * Date: 2017/10/9
 * Time: 10:26
 */

namespace Admin\Controller;


use Common\Common\FileSystem;
use Common\Common\ResponseResult;
use Common\Common\Validator;

class UploadFileController extends Controller
{
    public function image()
    {
        if (IS_POST) {
            $validator = Validator::make($_FILES, [
               'file' => ['required', 'file:image']
            ]);
            if ($validator->filed()) {
                ResponseResult::error(2000, $validator->error());
            }
            $path = FileSystem::uploadFile('file');
            ResponseResult::success($path);
        } else {
            ResponseResult::error(1000, 'Method Error');
        }
    }
}